/**
 * 
 */
package com.vector.ding.web.controller.report;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.vector.ding.commons.util.BeanUtil;
import com.vector.ding.commons.util.front.BuiUtil;
import com.vector.ding.dao.mybatis.model.GqtzgsBaseInfo;
import com.vector.ding.web.service.baseinfo.GqtzgsBaseInfoMgrService;
import com.vector.ding.web.service.report.SmtzReportService;

/**
 * @author vector
 *
 */
@Controller
@RequestMapping("/report/smtz")
public class SmtzReportController {
	
	@Autowired
	private SmtzReportService service;
	
	@Autowired
	private GqtzgsBaseInfoMgrService baseInfoServ;

	@RequestMapping(value="/view.do", method=RequestMethod.GET)
	public ModelAndView getViewPage() {
		return new ModelAndView("/report/smtz_report");
	}
	
	@RequestMapping(value="/detail.do", method=RequestMethod.GET)
	public ModelAndView getViewDetailPage(String comName) {
		ModelAndView mv = new ModelAndView();
		mv.addObject("comName", comName);
		mv.setViewName("/report/smtz_report_detail");
		return mv;
	}
	
	@RequestMapping(value="/basePage.do", method=RequestMethod.GET)
	public ModelAndView getBaseInfoPage(String comName) {
		GqtzgsBaseInfo info = baseInfoServ.getBaseInfoByName(comName);
		ModelAndView mv = new ModelAndView("/report/smtz_base_info");
		if (info != null) {
			mv.addAllObjects(BeanUtil.getPropertyMap(info));
		}
		return mv;
	}
	
	@RequestMapping(value="/bizPage.do", method=RequestMethod.GET)
	public ModelAndView getBizInfoPage(HttpServletRequest request,String comName) {
		ModelAndView mv = new ModelAndView();
		mv.addObject("comName", comName);
		mv.setViewName("/report/smtz_biz_info");
		return mv;
	}
	
	@RequestMapping(value="/mtpjPage.do", method=RequestMethod.GET)
	public ModelAndView getMtpjInfoPage(String comName) {
		ModelAndView mv = new ModelAndView();
		mv.addObject("comName", comName);
		mv.setViewName("/report/mtpj_info_mgr");
		return mv;
	}
	
	@RequestMapping(value="/hjxxPage.do", method=RequestMethod.GET)
	public ModelAndView getHjxxInfoPage(String comName) {
		ModelAndView mv = new ModelAndView();
		mv.addObject("comName", comName);
		mv.setViewName("/report/hjxx_info_mgr");
		return mv;
		//return new ModelAndView("/report/hjxx_info_mgr");
	}
	
	@ResponseBody
	@RequestMapping(value = "/getdata.do", method = RequestMethod.POST)
	public JSONObject getData(HttpServletRequest request, 
			int pageIndex, int limit) {
		List<Map<String,Object>> data = service.getSearchData(pageIndex+1, limit, request);
		return BuiUtil.gridAdapter(data);
	}
}
